#include<cstdio>
#include<stack>
#include<vector>
using namespace std;
int N;
vector<int> inp,path;
bool maxflag=true,minflag=true;

void DFS(int root){
    path.push_back(inp[root]);
    if(root*2+1<=N) DFS(root*2+1);
    if(root*2<=N) DFS(root*2);
    if(root*2>N && root*2+1>N){
        printf("%d",path[0]);
        for(int i=1;i<path.size();i++){
            printf(" %d",path[i]);
            if(path[i]>path[i-1]){maxflag=false;}
            if(path[i]<path[i-1]){minflag=false;}
        }
        printf("\n");
    }
    path.pop_back();
}

int main(){
    //freopen("in.txt","r",stdin);
    scanf("%d",&N);
    inp.resize(N+1);
    for(int i=1;i<=N;i++){scanf("%d",&inp[i]);}
    DFS(1);
    if(minflag==true){printf("Min Heap");}
    else if(maxflag==true){printf("Max Heap");}
    else{printf("Not Heap");}
}
